package snooker.scoreboard;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {

	private static final SimpleDateFormat format = 
		new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
	private static final NumberFormat nF = new DecimalFormat("0.00");
	
	public static String getDateString(Date date) {
		try {
			return format.format(date);
		} catch (Exception e) {
			return "";
		}
	}
	
	public static String getTimeString(long eventTime) {
		int inseconds = (int) (eventTime/1000);
		int seconds = (int) (inseconds % 60);
		int min = (int) (inseconds / 60);
		String r = "";
		if (seconds < 10) {
			r = min + ":0" + seconds;
		} else {
			r = min + ":" + seconds;
		}
		return r;
	}
	
	public static String formatDouble(double number) {
		return nF.format(number);
	}
}
